

import { _decorator, Node, Component, ScrollView, Prefab, size, v2 } from 'cc';
import { IData } from './TestShowNode';
import { LoopList } from '../Scripts/LoopListCell';
const { ccclass, property } = _decorator;

@ccclass
export class TestLoop extends Component {
    /**分层渲染节点 */
    @property(Node)
    public rendeLayer: Node = null;
    /**显示节点预制件 */
    @property(ScrollView)
    public scrollView: ScrollView = null;
    /**显示节点预制件 */
    @property(Prefab)
    public showPrefab: Prefab = null;

    start() {
        let data: IData[] = [];
        for (let i = 0, len = 30; i < len; ++i) {
            data.push({ index: i, text: "内容" + i, size: size(i % 2 == 0 ? 750 : 600, i % 2 == 0 ? 100 : 150) });
        }
        LoopList.ins<IData>("Test").init(this.scrollView, this.rendeLayer);
        LoopList.ins<IData>("Test").initData(data, this.showPrefab, size(750, 100), v2(0.5, 1));

        this.scheduleOnce(() => {
            LoopList.ins<IData>("Test").pushDatas([
                { index: 1, text: "我是压入1", size: size(600, 150) },
                { index: 2, text: "我是压入2", size: size(600, 150) },
                { index: 3, text: "我是压入3", size: size(600, 150) },
            ]);
        }, 3)
    }
}


